package com.wangku.springmvc.dataSource;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @Description: ${description}
 * @Param: ${params}
 * @return: ${returns}
 * @Author: 李赛赛
 * @Date: ${date}
 */
public class DynamicDataSource extends AbstractRoutingDataSource {
    @Override
    protected Object determineCurrentLookupKey() {
        return DataSourceContextHolder.getDataSourceType();
    }
    public static void setDataSource(String dataSource) {
        DataSourceContextHolder.setDataSourceType(dataSource);
    }

    public static String getDataSource() {
        return DataSourceContextHolder.getDataSourceType();
    }
    public static void clearDataSource() {
        DataSourceContextHolder.clearDataSourceType();
    }
}
